<div class="layui-card-body">
    <blockquote class="layui-elem-quote">注意：未支付或者是已经发货的不能批量发货</blockquote>
    <table class="layui-hide" id="batch_delivery" lay-filter="batch_delivery"></table>
    <script type="text/html" id="seller-seller-index-address_tmp">
        {{ d.prov }}{{ d.city }}{{ d.area }}{{ d.address }}
    </script>
</div>
<form class="layui-form" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">物流公司</label>
        <div class="layui-input-inline">
            <script type="text/html" template lay-url="{{ layui.setter.apiHost }}/system/express_company/select" lay-done="layui.form.render();">
                <select name="company_id">
                    <option value=""></option>
                    {{# layui.each(d.data, function(index, item){ }}
                    <option value="{{ item.id }}">{{ item.title }}</option>
                    {{# }); }}
                </select>
            </script>
        </div>
        <label class="layui-form-label">发货地址</label>
        <div class="layui-input-inline">
            <script type="text/html" template lay-url="{{ layui.setter.apiHost }}/seller/address/select" lay-done="layui.form.render();">
                <select name="address_id">
                    <option value=""></option>
                    {{# layui.each(d.data, function(index, item){ }}
                    <option value="{{ item.id }}">{{ item.address }}</option>
                    {{# }); }}
                </select>
            </script>
        </div>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="batch_delivery" value="发货" class="layui-btn">
        </div>
    </div>
</form>
<script type="text/html" template lay-done="layui.data.sendParams(d.params)"></script>
<script>
    layui.data.sendParams = function (params) {
        layui.use(function () {
            let table = layui.table,
                form = layui.form,
                common = layui.common,
                model_url = '/order/order';
            table.render({
                elem: '#batch_delivery',
                url: layui.setter.apiHost + model_url + '/batch_delivery_list',
                where: {id: params.id},
                cols: [[
                    {field: 'id', title: 'ID', width: 80},
                    {field: 'order_no', title: '订单号', width: 200},
                    {field: 'full_name', title: '收货人', width: 80},
                    {field: 'tel', title: '电话', width: 120},
                    {field: 'address', title: '地址', templet: '#address_tmp'},
                    {field: 'status_text', title: '状态', width: 120},
                ]],
                page: false,
                done: function () {
                    common.set_button(model_url);
                }
            });

            form.on('submit(batch_delivery)', function (data) {
                let form_data = data.field;
                form_data.id = params.id;
                common.action_ajax('batch_delivery_submit', form_data, true, 'batch_delivery')
                return false;
            })
        });
    }
</script>